import axios from "axios";

export interface IData<D> {
  code: number;
  msg: string;
  data: D;
}

const instance = axios.create({
  timeout: 10000,
  baseURL: "",
});

instance.interceptors.response.use(
  (res) => res.data,
  (err) => Promise.reject(err)
);


//get
export const get = <T>(url: string, config: any = {}) =>
  instance.get<any, IData<T>>(url, config);
  
//post
export const post = <T>(url: string, data: any, config: any = {}) =>
  instance.post<any, IData<T>>(url, data, config);


